<template>
  <div>
    <template v-if="$app.judgeData(orderInfo) && $app.judgeData(orLiInfo)"> 
      <Card class="marginB20" v-show="bigShowA">


        <!-- 0撰写中，1撰写完成待确认，2已合格，3不合格 -->
        <!-- 0或1 都显示这个模块 -->
        <template v-if="$app.judgeData(patent_files)">
          <div class="lineH34 c333 f_16 f_bold marginB10">专利撰写</div>

          <template v-if="patent_files[0].state>0">
            <!-- 0撰写中，1撰写完成待确认，2已合格，3不合格 -->
            <div>
              <div class="TJ_big paddingL30 f_18 cBlue">
                <div class="TJ_box paddingB20">
                  <Row :gutter="15" class="f_14 c666 marginB10">
                    <Col :span="12">
                      状态：
                      <span class="marginR20 f_16 " :class="patent_files[0].state==2?' cBlue f_bold ':' cRed '">{{patent_files[0].state_name}}</span>
                      <Button type="primary"  class="marginB10 relative" size="small" ghost shape="circle" v-show="patent_files[0].state==1" style="top:3px;"  @click="zCw">确 认</Button>
                    </Col>
                    <Col :span="12"></Col>
                  </Row>

                  <!-- 专利类型：1发明专利,2实用新型,3外观专利 -->
                  <template v-if="patent_files[0].patent_type==1||patent_files[0].patent_type==2">
                    <div class="pullLeft c666 f_14 marginR20" style="margin-top:6px;">
                      点击下载：
                    </div>
                    <div class="overflowH">
                      <div class="pullLeft " v-show="$app.judgeData(patent_files[0].instruction_path)" style="margin-right:50px;">
                        <div class=" textLine f_16 " @click="$app.openWindow(patent_files[0].instruction_path)">
                          <i class="iconfont marginR5 f_18" :class="$app.fileIcon(patent_files[0].instruction_path)"></i>
                          说明书
                        </div>
                      </div>
                      <div class="pullLeft " v-show="$app.judgeData(patent_files[0].instruction_abstract_path)" style="margin-right:50px;">
                        <div class=" textLine f_16" @click="$app.openWindow(patent_files[0].instruction_abstract_path)">
                          <i class="iconfont marginR5 f_18" :class="$app.fileIcon(patent_files[0].instruction_abstract_path)"></i>
                          说明书摘要
                        </div>
                      </div>
                      <div class="pullLeft " v-show="$app.judgeData(patent_files[0].claims_path)" style="margin-right:50px;">
                        <div class=" textLine f_16" @click="$app.openWindow(patent_files[0].claims_path)">
                          <i class="iconfont marginR5 f_18" :class="$app.fileIcon(patent_files[0].claims_path)"></i>
                          权利要求书
                        </div>
                      </div>
                      <div class="pullLeft " v-show="$app.judgeData(patent_files[0].instruction_image_path)" style="margin-right:50px;">
                        <div class=" textLine f_16" @click="$app.openWindow(patent_files[0].instruction_image_path)">
                          <i class="iconfont marginR5 f_18" :class="$app.fileIcon(patent_files[0].instruction_image_path)"></i>
                          说明书附图
                        </div>
                      </div>
                      <div class="pullLeft " v-show="$app.judgeData(patent_files[0].abstract_image_path)" style="margin-right:50px;">
                        <div class=" textLine f_16" @click="$app.openWindow(patent_files[0].abstract_image_path)">
                          <i class="iconfont marginR5 f_18" :class="$app.fileIcon(patent_files[0].abstract_image_path)"></i>
                          摘要附图
                        </div>
                      </div>
                      <div class="pullLeft " v-show="$app.judgeData(patent_files[0].patent_file_path)" style="margin-right:50px;">
                        <div class=" textLine f_16" @click="$app.openWindow(patent_files[0].patent_file_path)">
                          <i class="iconfont marginR5 f_18" :class="$app.fileIcon(patent_files[0].patent_file_path)"></i>
                          专利文件（五书合一）
                        </div>
                      </div>
                      
                    </div>
                    <div class="clearBoth"></div>
                    <div class="f_14 c666 marginT10 pullLeft  marginR30" v-show="$app.judgeData(patent_files[0].abstract_image_index)">
                      指定说明书附图中的图<span class="f_bold f_16 cBlue"> {{patent_files[0].abstract_image_index}} </span>为摘要附图
                    </div>
                    <div class="f_14 c666 marginT10 pullLeft" v-show="$app.judgeData(patent_files[0].claims_item_count)">
                      权利要求的项数<span class="f_bold f_16 cBlue"> {{patent_files[0].claims_item_count}} </span> 项
                    </div> 
                    <div class="clearBoth"></div>
                    
                  </template>

                  <!-- 专利类型：1发明专利,2实用新型,3外观专利 -->
                  <template v-if="patent_files[0].patent_type==3">
                    <div class="JC_img borderNone pointer relative pullLeft marginR30 marginB20 heightAuto" 
                      v-for="(jar,r) in patent_files[0].appe_img_list" :key="'appe_img_list'+r" 
                    >
                      <img :src="jar.file_url" class="cover  width100 marginB10" @click="$app.openWindow(jar.file_url)" style="height:120px;">
                      <div class=" f_12 c999 textCenter">{{$app.urlToName(jar)}}</div>
                    </div> 
                    <div class="clearBoth">
                      <span class=" textLine f_16" @click="$app.openWindow(patent_files[0].appe_brief_desc_path)">
                        <i class="iconfont marginR5 f_18" :class="$app.fileIcon(patent_files[0].appe_brief_desc_path)"></i>
                        外观简要说明书
                      </span>
                    </div>
                  </template>

                  <!-- state  本次专利撰写状态，0撰写中，1撰写完成待确认，2已合格，3不合格 -->
                  <template v-if="patent_files[0].state==3">
                    <div class="f_14 c666 marginT10 ">
                      不合格的原因：
                      <span class="c333">{{patent_files[0].remark}}</span>
                    </div>
                  </template>
                  
                </div>
              </div>
            </div>
            
          </template>
          <!-- 状态等于0 -->
          <template v-else>
            <div>
              <div class="TJ_big paddingL30 f_18 cCCC">
                撰写中，请耐心等待...
              </div>
            </div>
            
          </template>
          
          <!-- 0撰写中，1撰写完成待确认，2已合格，3不合格 -->
          <template v-if="patent_files.length>1 ">
            <div class="lineH34 c333 f_16 f_bold marginB10">
              撰写记录
              <Button type="primary"  class="marginB10 relative" style="top:3px;right:-10px;"  size="small" shape="circle" ghost  @click="history_zX=true">查看历史记录</Button>
            </div>
          </template>

          
        </template>
        
        
      </Card>
    </template>

    <!-- 评价合格不合格 -->
    <div class="zxDialog" v-show="zxDialog">
      <div class="content textCenter">
        <Icon type="md-close" class="absolute f_20 cCCC pointer" style="top:90px; right:15px; z-index:920;" @click="zxDialog=false" />
        <img :src="zX_ok" class="topTips inlineBlock" >
        <div class="contentBox">
          <div style="padding-top:60px;">
            <Row :gutter="15" class=" paddingB10 f_18">
              <Col :span="2" class="marginB10"></Col>
              
              <Col :span="20" class="marginB10 ">
                <RadioGroup v-model="heGe">
                    <Radio :label="2" style="margin-right:50px;">
                        <Icon type="md-checkmark" class="f_24 cGreen marginR5" />
                        <span class="f_20">确认无误</span>
                    </Radio>
                    <Radio :label="3">
                        <Icon type="md-close"  class="f_24 cRed marginR5"/>
                        <span class="f_20">还需修改</span>
                    </Radio>
                </RadioGroup>
              </Col>
              <Col :span="2" class="marginB10"></Col>
            </Row>
            <Row :gutter="15" class=" paddingB20 f_18" v-show="heGe==3">
              <Col :span="2" class="marginB10"></Col>
              
              <Col :span="20" class="marginB10">
                <Input
                  class="tempFW"
                  :placeholder="'请输入备注'"
                  size="large"
                  v-model="remark"
                  ref="remark"
                  clearable
                  type="textarea"
                  :rows="5"
                />
              </Col>
              <Col :span="2" class="marginB10"></Col>
            </Row>
            


            <div class="textCenter">
              <Button type="primary" class="marginB10 " size="large" style="width:40%"  @click="goFun">提 交</Button>
            </div>
          </div>
        </div>
      </div>
      <div class="mask"></div>
    </div>



    <Modal
      v-model="history_zX"
      title="撰写记录"
      :footer-hide="true"
      :mask-closable="false"
      width="1000"
      class-name="vertical-center-modal"
    > 
      <div class="xDgao" :style="`overflow-y:auto;margin:-16px;max-height:${$app.winHeight-100}px`">
        <!-- 撰写历史记录 -->
        <template v-if="$app.judgeData(patent_files)">
          <div class="paddingLi">
            <!-- 0撰写中，1撰写完成待确认，2已合格，3不合格 -->
            <template v-if="val.state>1" v-for="(val,i) in patent_files" >
                <div class="TJ_big  f_18 cBlue">
                  <div class="TJ_box paddingB20 padding0-10">
                    <div class="f_14 c666 marginB10">
                      <span class="inlineBlock" style="width:200px;">状态：<span class=" f_18 " :class="val.state==2?' cBlue f_bold ':' cRed '">{{val.state_name}}</span></span>
                      <span>时间：{{val.created_at}}</span>
                    </div>

                    <!-- 专利类型：1发明专利,2实用新型,3外观专利 -->
                    <template v-if="val.patent_type==1||val.patent_type==2">
                      <div class="pullLeft c666 f_14 marginR20" style="margin-top:6px;">
                        点击下载：
                      </div>
                      <div class="overflowH">
                        <div class="pullLeft " v-show="$app.judgeData(val.instruction_path)" style="margin-right:30px;">
                          <div class=" textLine f_16 " @click="$app.openWindow(val.instruction_path)">
                            <i class="iconfont marginR5 f_18" :class="$app.fileIcon(val.instruction_path)"></i>
                            说明书
                          </div>
                        </div>
                        <div class="pullLeft " v-show="$app.judgeData(val.instruction_abstract_path)" style="margin-right:30px;">
                          <div class=" textLine f_16" @click="$app.openWindow(val.instruction_abstract_path)">
                            <i class="iconfont marginR5 f_18" :class="$app.fileIcon(val.instruction_abstract_path)"></i>
                            说明书摘要
                          </div>
                        </div>
                        <div class="pullLeft " v-show="$app.judgeData(val.claims_path)" style="margin-right:30px;">
                          <div class=" textLine f_16" @click="$app.openWindow(val.claims_path)">
                            <i class="iconfont marginR5 f_18" :class="$app.fileIcon(val.claims_path)"></i>
                            权利要求书
                          </div>
                        </div>
                        <div class="pullLeft " v-show="$app.judgeData(val.instruction_image_path)" style="margin-right:30px;">
                          <div class=" textLine f_16" @click="$app.openWindow(val.instruction_image_path)">
                            <i class="iconfont marginR5 f_18" :class="$app.fileIcon(val.instruction_image_path)"></i>
                            说明书附图
                          </div>
                        </div>
                        <div class="pullLeft " v-show="$app.judgeData(val.abstract_image_path)" style="margin-right:30px;">
                          <div class=" textLine f_16" @click="$app.openWindow(val.abstract_image_path)">
                            <i class="iconfont marginR5 f_18" :class="$app.fileIcon(val.abstract_image_path)"></i>
                            摘要附图
                          </div>
                        </div>
                        <div class="pullLeft " v-show="$app.judgeData(val.patent_file_path)" style="margin-right:30px;">
                          <div class=" textLine f_16" @click="$app.openWindow(val.patent_file_path)">
                            <i class="iconfont marginR5 f_18" :class="$app.fileIcon(val.patent_file_path)"></i>
                            专利文件（五书合一）
                          </div>
                        </div>
                      </div>

                      <div class="clearBoth"></div>
                      <div class="f_14 c666 marginT10 pullLeft  marginR30" v-show="$app.judgeData(val.abstract_image_index)">
                        指定说明书附图中的图<span class="f_bold f_16 cBlue"> {{val.abstract_image_index}} </span>为摘要附图
                      </div>
                      <div class="f_14 c666 marginT10 pullLeft" v-show="$app.judgeData(val.claims_item_count)">
                        权利要求的项数<span class="f_bold f_16 cBlue"> {{val.claims_item_count}} </span> 项
                      </div> 
                      <div class="clearBoth"></div>
                    </template>
                    <!-- 专利类型：1发明专利,2实用新型,3外观专利 -->
                    <template v-if="val.patent_type==3">
                      <div class="JC_img borderNone pointer relative pullLeft marginR30 marginB20 heightAuto"
                        v-for="(jar,r) in val.appe_img_list" :key="'appe_img_list'+r" 
                      >
                        <img :src="jar.file_url" class="cover  width100 marginB10" @click="$app.openWindow(jar.file_url)" style="height:120px;">
                        <div class=" f_12 c999 textCenter">{{$app.urlToName(jar)}}</div>
                      </div> 
                      <div class="clearBoth">
                        <span class=" textLine f_16" @click="$app.openWindow(val.appe_brief_desc_path)">
                          <i class="iconfont marginR5 f_18" :class="$app.fileIcon(val.appe_brief_desc_path)"></i>
                          外观简要说明书
                        </span>
                      </div>
                    </template>
                    <div class="f_14 c666 marginT10" v-show="$app.judgeData(val.remark)">原因：<span class=" ">{{val.remark}}</span></div>

                  </div>
                </div>
              
            </template>
          </div>
        </template>
        <template v-else>
          <div class="paddingLi cCCC textCenter">
            暂无记录
          </div>
        </template>
      </div>
      
	  
	  
    </Modal>



  </div>
</template>


<style lang="less" scoped>
// 弹框
.zxDialog{
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  margin: auto;
  z-index: 901;
  .mask{
    position: fixed;
    z-index: 902;
    background-color: rgba(55, 55, 55, 0.6);
    height: 100%;
    width: 100%;
  }

  .content{
    position: fixed;
    z-index: 903;
    height: 410px;
    width: 500px;
    top: -100px;
    bottom: 0;
    left: 0;
    right: 0;
    margin: auto;
    overflow: hidden;
    -webkit-animation: comeIn 0.3s linear;
    animation: comeIn 0.3s linear;
    .topTips{
      position: relative;
      z-index: 905;
      top:40px;
    }
    .contentBox{
      background-color: white;
      padding-bottom:20px;
      border-radius: 10px;
    }
  }
}

</style>


<script>


import zX_ok from '@$@/img/zX_ok.png';
export default {
  name: "patentWrite",
  components: { },
  props: ["orderInfo", "orLiInfo"],
  data() {
    let data = {
      
      patent_files:[],//专利撰写记录，数组的第一条是最新，后面的是历史
      heGe:2,//2已合格，3不合格
      remark:'',//备注信息
      
    };

    let tool = {
      
      
      zX_ok,
      history_zX:false,
      zxDialog:false,
      bigShowA:false,
      zheDie:false,//true折叠 false不折叠
    };
    return Object.assign(data, tool);
  },
  watch: {
    
    zxDialog(){
      this.heGe=2;
      this.remark='';
    },
    heGe(newVal, oldVal){
      this.remark='';
    },
  },
  mounted() {
    this.getData();


    
  },
  methods: {
    // 显示确认框
    zCw(){
      this.zxDialog=true;
    },
    // 获取第三方撰写好的文件，可以下载
    getData(){
      this.heGe=2;
      this.remark='';

      let {
        orLiInfo:{
          goods_type
        },
        $route:{
          query:{
            order_id
          }
        }
      }=this;

      // 获取第三方撰写信息
      $ajax.patentFilesDown(order_id,resData=>{
        if($app.judgeData(resData)){
          let {
            patent_files,//撰写的文件
            writer
          }=resData;

          this.patent_files=patent_files;//返回数组，直接赋值
          if($app.judgeData(patent_files)){
            this.bigShowA=true;//有第三方撰写数据
          }
        }
      });

      

    },

    


    //弹框切换函数
    vChange(buEr){
      if(!buEr){
        
      }
    },

    
    
    //算 折叠框
    suanZeDie(){
      
      //专利类型：1发明专利,2实用新型,3外观专利
      let{
        patent_files,
        zheDie
      }=this;

      let out ='';

      if($app.judgeData(patent_files)){
        let patent_type=patent_files[0].patent_type;
        if(patent_type<3){
          zheDie?(out =' pT12 '):(out ='');
        }else{
          zheDie?(out =' pT3 '):(out ='');
        }
      }

      return out;

      

    },

    //确认评论
    goFun(){
      let{
        heGe:state,
        remark,
        patent_files
      }=this;

      this.zxDialog=false;

      //反馈专利撰写文件是否合格
      $ajax.patentFilesCheck(patent_files[0].id,state,remark,resData=>{

        //刷新数据
        this.getData();
        this.$parent.getData();//刷新父级数据

      });

    }

  }
};
</script>

